class Solution(object):
    def isPerfectSquare(self, num):
        """
        :type num: int
        :rtype: bool
        """
        l = 0
        h = num
        while l <= h:
            mid = l + (h - l) / 2
            square = mid * mid
            if square == num:
                return True
            if square > num:
                h = mid - 1
            else:
                l = mid + 1
        return False
